package cn.wxq.daily.empdailymgforserve.service.impl;

import cn.wxq.daily.empdailymgforserve.domain.Salary;
import cn.wxq.daily.empdailymgforserve.mapper.SalaryDao;
import cn.wxq.daily.empdailymgforserve.service.SalaryService;
import org.apache.ibatis.executor.loader.cglib.CglibProxyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 工资业务层
 */
@Service
public class SalaryServiceImpl implements SalaryService{
    @Autowired
    private SalaryDao salaryDao;

    /**
     * 录入
     * @param salary
     * @return
     */

    @Override
    public int addSalary(Salary salary) {
        //应发工资：初始化为基本工资
        salary.setAllSalary(salary.getBasicSalary());
        salary.setShouldSalary(salary.getBasicSalary());
        //启用时间为录入时间
        salary.setCreateDate(new Date());
        return salaryDao.addSalary(salary);

    }

    /**
     * 条件查询
     * @param salary
     * @return
     */
    @Override
    public List<Salary> getSalaryByPage(Salary salary) {
        return salaryDao.getSalaryByPage(salary);
    }

    /**
     * 更新
     * @param salary
     * @return
     */
    @Override
    public int updateSalary(Salary salary) {
        return salaryDao.updateSalary(salary);
    }

    /**
     * 删除
     * @param sId
     * @return
     */
    @Override
    public int deleteSalary(Integer sId) {
        return salaryDao.deleteSalary(sId);
    }

    /**
     * id获取详情
     * @param sId
     * @return
     */
    @Override
    public Salary getInfoById(Integer sId) {
        return salaryDao.getInfoById(sId);
    }
}
